package com.codingfuture.glaciercommon.util;

import com.codingfuture.glaciercommon.exception.ReqPageParamExciption;
import lombok.Getter;
import lombok.ToString;

import static com.codingfuture.glaciercommon.util.Result.*;

/**
 * @author :zxw
 * @date 2025-03-31 17:14
 * @description:
 */
@Getter
@ToString
public class PageParam {
    private Integer pageNum =DEFAULT_PAGE_NUM;
    private Integer pageSize=DEFAULT_PAGE_SIZE;

    public void setPageNum(Integer pageNum) {

        if(pageNum<=ZERO){
            throw new ReqPageParamExciption();
        }
        this.pageNum = pageNum;
    }

    public void setPageSize(Integer pageSize) {
        if(pageSize<=ZERO || pageSize%PAGE_SIZE_STEP!=ZERO||pageSize>PAGE_SIZE_MAX){
            throw new ReqPageParamExciption();
        }
        this.pageSize = pageSize;
    }
}
